
#ifndef __PUBLIC_H__
#define __PUBLIC_H__

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>

#include <gtk/gtk.h>

#include "protocol.h"
#include "logout.h"

#define DEF_BUFMAX 8192

#define USER_STAT_NORMAL        1
#define USER_STAT_REGISTERED    2
#define USER_STAT_LOGINED		3
#define USER_STAT_LOGOUTED		4

struct u_session_t
{
	int conn;
	char recvbuf[DEF_BUFMAX];
	int recvlen;
	char sendbuf[DEF_BUFMAX];
	int sendlen;
	int stat;
};

struct u_session_t user_session;
struct user_info_t user_info;

#define DEF_FRIEND_MAX   	128
#define DEF_GROUP_MAX		128
#define DEF_GROUP_USER_MAX 	128

struct user_info_t friend_list[DEF_FRIEND_MAX];

struct group_list_t
{
	struct group_info_t group_info;
	struct user_info_t user_list[DEF_GROUP_USER_MAX];
} group_list[DEF_GROUP_MAX];

int pack_send(struct u_session_t *session, int type, char *data, int len);
int write_data(struct u_session_t *session, char *data, int len);

int dlg_ok(GtkWindow *window, char *msg);
int dlg_close(GtkWindow *window, char *msg);
int dlg_cancel(GtkWindow *window, char *msg);
int dlg_yes_no(GtkWindow *window, char *msg);
int dlg_ok_cancel(GtkWindow *window, char *msg);

#endif // __PUBLIC_H__

